﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace frmViewItemCatalog
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        LogicUniversityT2Entities logic = new LogicUniversityT2Entities();
        protected void Page_Load(object sender, EventArgs e)
        {
            var itemList = (from items in logic.Items
                     select new
                     {
                         ItemID = items.ItemID,
                         ItemDescription = items.ItemDescription,
                     //    AvgPrice =,
                         UOM = items.UOM
                     });
            var itemlist = itemList.ToList();
            gvItemList.DataSource = itemlist;
            gvItemList.DataBind();
        }
        private double calculateAveragePrice()
        {

            string selectItemID = gvItemList
            double avgPrice = 0.0;
            
                              System.Nullable<Decimal>AverageUnitPrice =
                               Convert.ToDecimal((from itemDetail in context.ItemDetails
                                  where itemDetail.ItemID == selectItemID
                                 select itemDetail.Price).Average());

                              avgPrice = Convert.ToDouble(AverageUnitPrice);
            

                
              return avgPrice;

            }
        }

    }
}